#ifndef _I2C2_H
#define _I2C2_H


#define I2C2_DEV_NAME                      "/dev/i2c-2"

#define I2C_M_RD	0x01   //表示这是一个读操作，默认是把相应的位置1
#define I2C_RETRIES	0x0701	/*设置收不到ACK时的重试次数*/
#define I2C_TIMEOUT	0x0702	/* 设置超时时限的 */
#define I2C_RDWR	0x0707	/* Combined R/W transfer (one stop only)*/

class i2c2
{
private:
    static int i2cfd;
    struct i2c_msg {
        unsigned short addr;     /* slave address */
        unsigned short flags;
        unsigned short len;
        unsigned char *buf;     /* message data pointer */
    };
    struct i2c_rdwr_ioctl_data {
        struct i2c_msg *msgs;   /* i2c_msg[] pointer */
        int nmsgs;              /* i2c_msg Nums */
    };
    
public:
    int i2c_write(unsigned char slave, unsigned char reg, unsigned char value);
    int i2c_read(unsigned char slave, unsigned char reg, unsigned char *buf);
    i2c2(/* args */);
    ~i2c2();

    static int i2c2_init();
};

#endif